/*
 * @Author: zxc
 * @Date: 2020-11-11 14:51:34
 * @LastEditTime: 2020-11-11 15:10:40
 * @LastEditors: zxc
 * @Description:整数转罗马数字
 */
/**
 * @param {number} num
 * @return {string}
 */
var intToRoman = function (num) {
  let numArrs = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],
    codeArrs = [
      "M",
      "CM",
      "D",
      "CD",
      "C",
      "XC",
      "L",
      "XL",
      "X",
      "IX",
      "V",
      "IV",
      "I"
    ],
    res = "",
    idx = 0
  while (idx < numArrs.length) {
    while (num >= numArrs[idx]) {
      res += codeArrs[idx]
      num -= numArrs[idx]
    }
    idx++
  }

  return res
}
